<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePatentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('patents', function (Blueprint $table) {
            $table->id();
            $table->integer('patent_apply_id')->default(0)->after('id');
            $table->string('uuid',32)->nullable()->comment('登记号');
            $table->string('patent_sn', 20)->comment('专利号');
            $table->string('patent_name')->comment('专利名称');
            $table->date('apply_date')->nullable()->comment('申请日期');
            $table->integer('patent_type_id')->default(0)->comment('专利类型ID');
            $table->string('patent_person',50)->nullable()->comment('专利权人');
            $table->string('applicant')->nullable()->comment('申请人');
            $table->string('inventor')->nullable()->comment('发明人设计人');

            $table->string('legal_status', 50)->nullable()->comment('案例状态');
            $table->string('ipc_main', 50)->nullable()->comment('主分类号');
            $table->string('ipc')->nullable()->comment('分类号');

            $table->string('publication_num')->nullable();
            $table->date('publication_date')->nullable();

            $table->string('agency', 30)->nullable()->comment('代理机构');
            $table->string('agent', 20)->nullable()->comment('第一代理人');

            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->integer('department_id')->default(0)->comment('院系ID');

            $table->tinyInteger('keep_status')->default(1)->comment('0放弃维持,1维持状态');
            $table->string('state')->default(1)->comment('状态');
            $table->tinyInteger('is_monitor')->default(0)->comment('年费监控');

            $table->decimal('score')->default(0)->comment('评分');
            $table->text('assessment')->nullable()->comment('评估信息');

            $table->timestamps();

            $table->index('patent_apply_id');
            $table->index('user_id');
            $table->index('department_id');
            $table->index('patent_sn');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('patents');
    }
}
